package com.seeyon.apps.bense.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 日期处理工具类
 * @author FanGaowei
 * @date 2018年5月23日上午9:05:36
 * @Copyright Beijing Seeyon Software Co.,LTD
 */
public class DateKit {

    private static SimpleDateFormat simple = new SimpleDateFormat("yyyyMMdd");

    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    private static SimpleDateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd");

    public static String getSimpleDate(Date date) {
        if(date == null) {
            return "";
        }
        return dayFormat.format(date);
    }

    public static String getDateString(Date date) {
        if(date == null) {
            return "";
        }
        return sdf.format(date);
    }

    public static String getDayDate(Date date) {
        if(date == null) {
            return "";
        }
        return dayFormat.format(date);
    }

    /**
     * Description:
     * 
     * <pre>
     * 获取多少天以后的日期
     * </pre>
     * 
     * @param day
     * @return
     */
    public static Date getDayAfter(int day) {
        Calendar cal = Calendar.getInstance();
        cal.add(Calendar.DATE, day);
        return cal.getTime();
    }
    
    public static Date getdayDate(String dateStr) throws Exception {
    	return dayFormat.parse(dateStr);
    }
}
